<template>
  <div class="resume">
    <div class="resume-header">
      <h1>个人简历</h1>
      <div class="header-actions">
        <a :href="basic.resumeLink" download class="download-btn">
          <i class="btn-icon">📄</i>
          下载简历
        </a>
      </div>
    </div>

    <div class="timeline-container">
      <div class="basic-info-section">
        <h2>基本信息</h2>
        <div class="info-grid">
          <div class="info-item">
            <span class="label">姓名：</span>
            <span>{{ basic.name }} ({{ basic.englishName }})</span>
          </div>
          <div class="info-item">
            <span class="label">职位：</span>
            <span>{{ basic.title }}</span>
          </div>
          <div class="info-item">
            <span class="label">地址：</span>
            <span>{{ basic.location }}</span>
          </div>
          <div class="info-item">
            <span class="label">邮箱：</span>
            <span>{{ basic.email }}</span>
          </div>
        </div>
      </div>

      <div class="timeline-section">
        <h2>工作经历</h2>
        <div class="timeline">
          <div 
            v-for="job in workExperience" 
            :key="job.id" 
            class="timeline-item"
          >
            <div class="time-period">{{ job.period }}</div>
            <div class="content">
              <h3>{{ job.title }}</h3>
              <div class="company">{{ job.company }}</div>
              <ul class="achievements">
                <li v-for="(achievement, index) in job.achievements" :key="index">
                  {{ achievement }}
                </li>
              </ul>
            </div>
          </div>
        </div>
      </div>

      <div class="education-section" v-if="siteConfig.education">
        <h2>教育背景</h2>
        <div class="timeline">
          <div 
            v-for="(edu, index) in siteConfig.education" 
            :key="index"
            class="timeline-item"
          >
            <div class="time-period">{{ edu.period }}</div>
            <div class="content">
              <h3>{{ edu.degree }}</h3>
              <div class="school">{{ edu.school }}</div>
              <p class="description">{{ edu.description }}</p>
            </div>
          </div>
        </div>
      </div>

      <div class="skills-section" v-if="siteConfig.skills">
        <h2>技能图谱</h2>
        <div class="skills-container">
          <div class="skill-category">
            <h3>前端技能</h3>
            <div class="skill-bars">
              <div 
                v-for="skill in siteConfig.skills.frontend" 
                :key="skill.name"
                class="skill-bar"
              >
                <span class="skill-name">{{ skill.name }}</span>
                <div class="bar">
                  <div 
                    class="bar-fill"
                    :style="{ width: `${skill.level}%` }"
                  ></div>
                </div>
                <span class="skill-level">{{ skill.level }}%</span>
              </div>
            </div>
          </div>
          <div class="skill-category">
            <h3>后端技能</h3>
            <div class="skill-bars">
              <div 
                v-for="skill in siteConfig.skills.backend" 
                :key="skill.name"
                class="skill-bar"
              >
                <span class="skill-name">{{ skill.name }}</span>
                <div class="bar">
                  <div 
                    class="bar-fill"
                    :style="{ width: `${skill.level}%` }"
                  ></div>
                </div>
                <span class="skill-level">{{ skill.level }}%</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { siteConfig } from '../config/site'

const basic = ref(siteConfig.basic)
const workExperience = ref(siteConfig.workExperience)

onMounted(() => {
  console.log('Resume data:', {
    basic: basic.value,
    workExperience: workExperience.value
  })
})
</script>

<style lang="scss" scoped>
.resume {
  padding: 80px 20px;
  max-width: 1200px;
  margin: 0 auto;

  .resume-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;

    h1 {
      font-size: 3rem;
      color: var(--primary-color);
      margin: 0;
    }

    .download-btn {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 1rem 2rem;
      background: var(--primary-color);
      color: white;
      text-decoration: none;
      border-radius: 25px;
      font-size: 1.2rem;
      transition: all 0.3s ease;

      &:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(var(--primary-color-rgb), 0.3);
      }

      .btn-icon {
        font-size: 1.4rem;
      }
    }
  }
}

.timeline-section,
.basic-info-section,
.education-section,
.skills-section {
  margin-bottom: 3rem;
  padding: 2rem;
  background: rgba(var(--background-color-rgb), 0.5);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);

  h2 {
    font-size: 1.8rem;
    color: var(--text-color);
    margin-bottom: 2rem;
    position: relative;
    padding-left: 1rem;

    &::before {
      content: '';
      position: absolute;
      left: 0;
      top: 0;
      bottom: 0;
      width: 4px;
      background: var(--primary-color);
      border-radius: 2px;
    }
  }
}

.basic-info-section {
  margin-bottom: 2rem;

  .info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    
    .info-item {
      display: flex;
      gap: 0.8rem;
      padding: 0.8rem;
      background: rgba(var(--primary-color-rgb), 0.05);
      border-radius: 8px;
      
      .label {
        font-weight: bold;
        color: var(--primary-color);
        min-width: 60px;
      }
    }
  }
}

.timeline {
  position: relative;
  padding-left: 2rem;

  &::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(var(--primary-color-rgb), 0.2);
  }

  .timeline-item {
    position: relative;
    padding-bottom: 2rem;
    
    &:last-child {
      padding-bottom: 0;
    }

    &::before {
      content: '';
      position: absolute;
      left: -2rem;
      top: 0;
      width: 1rem;
      height: 1rem;
      border-radius: 50%;
      background: var(--primary-color);
      border: 3px solid var(--background-color);
      box-shadow: 0 0 0 4px rgba(var(--primary-color-rgb), 0.1);
    }

    .time-period {
      font-size: 1.2rem;
      color: var(--primary-color);
      margin-bottom: 1rem;
      font-weight: bold;
    }

    .content {
      h3 {
        font-size: 1.4rem;
        margin-bottom: 0.5rem;
        color: var(--text-color);
      }

      .company {
        font-size: 1.2rem;
        color: var(--text-color);
        opacity: 0.8;
        margin-bottom: 1rem;
      }

      .achievements {
        list-style: none;
        padding: 0;

        li {
          position: relative;
          padding-left: 1.5rem;
          margin-bottom: 0.5rem;
          font-size: 1.1rem;
          color: var(--text-color);
          opacity: 0.8;
          line-height: 1.6;

          &::before {
            content: '•';
            position: absolute;
            left: 0;
            color: var(--primary-color);
          }

          &:last-child {
            margin-bottom: 0;
          }
        }
      }
    }
  }
}

.skills-section {
  margin-top: 2rem;

  .skills-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;

    .skill-category {
      h3 {
        margin-bottom: 1.5rem;
        color: var(--primary-color);
        font-size: 1.3rem;
      }
    }

    .skill-bar {
      margin-bottom: 1rem;
      padding: 0.5rem;
      background: rgba(var(--background-color-rgb), 0.8);
      border-radius: 6px;
      transition: all 0.3s ease;
      
      &:hover {
        background: rgba(var(--primary-color-rgb), 0.05);
      }
      
      .skill-name {
        display: block;
        margin-bottom: 0.5rem;
        font-weight: 500;
      }

      .bar {
        height: 8px;
        background: rgba(var(--primary-color-rgb), 0.1);
        border-radius: 4px;
        overflow: hidden;

        .bar-fill {
          height: 100%;
          background: var(--primary-color);
          transition: width 0.6s ease;
        }
      }

      .skill-level {
        display: block;
        text-align: right;
        font-size: 0.9rem;
        color: var(--text-color);
        opacity: 0.8;
        margin-top: 0.3rem;
      }
    }
  }
}

@media (max-width: 768px) {
  .resume {
    padding: 40px 1rem;

    .resume-header {
      flex-direction: column;
      gap: 1.5rem;
      text-align: center;

      h1 {
        font-size: 2.2rem;
      }
    }
  }

  .timeline-section,
  .basic-info-section,
  .education-section,
  .skills-section {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
  }

  .timeline {
    .timeline-item {
      .content {
        h3 {
          font-size: 1.3rem;
        }

        .company {
          font-size: 1.1rem;
        }
      }
    }
  }
}
</style> 